/**
 *  OSTV - Jscript
 */	
 

  var dimmed = 0;
  function toggleLights()
  {
    var dimmer = document.getElementById("dimmer");
    if(dimmed == 0) dimmed = 1;
    else dimmed = 0;

    if(dimmed == 1)
    {
        dimmer.style.opacity = 0.97;
        dimmer.style.visibility = "visible";
    }

    if(dimmed == 0)
    {
        dimmer.style.opacity = 0.0;
        dimmer.style.visibility = "hidden";
    }
  }

function vsrc_scroll() {
	vsrc_obj.scrollTop = vsrc_obj.scrollTop + 1;
	vsrc_scrollPos++;
	if ((vsrc_scrollPos%vsrc_heightOfElm) == 0) {
		vsrc_numScrolls--;
		if (vsrc_numScrolls == 0) {
			vsrc_obj.scrollTop = '0';
			vsrc_content();
		} else {
			if (vsrc_scrollOn == 'true') {
				vsrc_content();
			}
		}
	} else {
		setTimeout("vsrc_scroll();", 10);
	}
}

var vsrc_Num = 0;

function vsrc_content() {
	var tmp_vsrc = '';

	w_vsrc = vsrc_Num - parseInt(vsrc_numberOfElm);
	if (w_vsrc < 0) {
		w_vsrc = 0;
	} else {
		w_vsrc = w_vsrc%vsrc_array.length;
	}
	
	// Show amount of vsrru
	var elementsTmp_vsrc = parseInt(vsrc_numberOfElm) + 1;
	for (i_vsrc = 0; i_vsrc < elementsTmp_vsrc; i_vsrc++) {
		
		tmp_vsrc += vsrc_array[w_vsrc%vsrc_array.length];
		w_vsrc++;
	}

	vsrc_obj.innerHTML 	= tmp_vsrc;
	
	vsrc_Num 			= w_vsrc;
	vsrc_numScrolls 	= vsrc_array.length;
	vsrc_obj.scrollTop 	= '0';
	// start scrolling
	setTimeout("vsrc_scroll();", 2000);
}

function hide() {
    document.getElementById('chat').style.display='none';
    document.getElementById('hide_chat').style.display='none';
    document.getElementById('show_chat').style.display='block';
}

function show() {
    document.getElementById('chat').style.display='block';
    document.getElementById('show_chat').style.display='none';
    document.getElementById('hide_chat').style.display='block';
}

function Browser() {
var ua, s, i;
this.isIE = false;
this.isNS = false;
this.version = null;
ua = navigator.userAgent;
s = "MSIE";
if ((i = ua.indexOf(s)) >= 0) {
this.isIE = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}

s = "Netscape6/";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = parseFloat(ua.substr(i + s.length));
return;
}

s = "Gecko";
if ((i = ua.indexOf(s)) >= 0) {
this.isNS = true;
this.version = 6.1;
return;
}
}

var browser = new Browser();
var dragObj = new Object();
dragObj.zIndex = 0;

function dragStart(event, id) {
var el;
var x, y;

if (id)
dragObj.elNode = document.getElementById(id);
else {

if (browser.isIE)
dragObj.elNode = window.event.srcElement;

if (browser.isNS)
dragObj.elNode = event.target;

if (dragObj.elNode.nodeType == 3)
dragObj.elNode = dragObj.elNode.parentNode;
}

if (browser.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}

if (browser.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}

dragObj.cursorStartX = x;
dragObj.cursorStartY = y;
dragObj.elStartLeft = parseInt(dragObj.elNode.style.left, 10);
dragObj.elStartTop = parseInt(dragObj.elNode.style.top, 10);

if (isNaN(dragObj.elStartLeft)) dragObj.elStartLeft = 0;

if (isNaN(dragObj.elStartTop)) dragObj.elStartTop = 0;
dragObj.elNode.style.zIndex = ++dragObj.zIndex;

if (browser.isIE) {
document.attachEvent("onmousemove", dragGo);
document.attachEvent("onmouseup", dragStop);
window.event.cancelBubble = true;
window.event.returnValue = false;
}

if (browser.isNS) {
document.addEventListener("mousemove", dragGo, true);
document.addEventListener("mouseup", dragStop, true);
event.preventDefault();
}
}

function dragGo(event) {
var x, y;

if (browser.isIE) {
x = window.event.clientX + document.documentElement.scrollLeft
+ document.body.scrollLeft;
y = window.event.clientY + document.documentElement.scrollTop
+ document.body.scrollTop;
}

if (browser.isNS) {
x = event.clientX + window.scrollX;
y = event.clientY + window.scrollY;
}

dragObj.elNode.style.left = (dragObj.elStartLeft + x - dragObj.cursorStartX) + "px";
dragObj.elNode.style.top = (dragObj.elStartTop + y - dragObj.cursorStartY) + "px";

if (browser.isIE) {
window.event.cancelBubble = true;
window.event.returnValue = false;
}

if (browser.isNS)
event.preventDefault();
}

function dragStop(event) {

if (browser.isIE) {
document.detachEvent("onmousemove", dragGo);
document.detachEvent("onmouseup", dragStop);
}

if (browser.isNS) {
document.removeEventListener("mousemove", dragGo, true);
document.removeEventListener("mouseup", dragStop, true);
}
}